<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:include page="../include/header.jsp"></jsp:include>
<script type="text/javascript">
   $(function(){
	   $("#jqGrid").jqGridUtils({
			"url":"jqGrid/queryTree/org_mgr_tree_list.do",
			"colModel":[
			            {label: "ID",name: "id",width:200, hidden:true, key:true},
			            {label: "名称" ,name: "orgName",width:250},
			            {label: "类型" ,name: "orgType",width:100},
			            {label: "状态" ,name: "state",width:100},
			            {label: "编号" ,name: "code",width:100},
			            {label: "序号" ,name: "sortNum",width:50},
			            {label: "层级" ,name: "showLevel",width:50}],
			//caption: "组织机构列表",
			tableTitleIcon: "fa-sitemap",
			"gridview":true,
			"rowNum":10000,
			tableStyle:"table table-bordered",
			"scrollrows":true,
			"treeGrid":true,
			"ExpandColumn":"orgName",
			"ExpandColClick" : true,
			"treeGridModel":"adjacency",
			"datatype":"json",
			"pager":"#jqGridPager"
		});
	   $("#jqGrid").jqGrid('navGrid','#jqGridPager',
			   {add:true,addfunc: function(){
				   //获取选中数据
				   var id=$("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   id = "0";
				   }
				   //提出弹出窗口
				   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('添加组织机构', 'org/add.do?jqGridId=jqGrid&id='+id, 'fa fa-plus', null, null, function(){
					   window.parent.MixElementListener.initEvent();
				   });
			   }, edit:true,editfunc:function(){
				 //获取选中数据
				   var id = $("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   window.parent.BootstrapDialogUtil.warningAlert(null,"请选择一条要编辑的数据！");
				   } else {
					   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('修改组织机构', 'org/edit.do?id='+id+'&jqGridId=jqGrid', 'fa fa-pencil-square-o', null, null, function(){
						   window.parent.MixElementListener.initEvent();
					   });
				   }
			   }, del:true,delfunc:function(){
				 //获取选中数据
				   var id = $("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   window.parent.BootstrapDialogUtil.warningAlert(null,"请选择一条要删除的数据！");
				   } else {
					   window.parent.BootstrapDialogUtil.delDialog(null,"选中的组织机构",'org/delete.do',id,function(){
						 //$("#jqGrid").trigger("reloadGrid");
						 refreshJqGrid();
					 });
				 }
			   }, view:false, search:false},{id:'edit'},{id:'add'});
   });
   //刷新列表
   function refreshJqGrid() {
	   $("#jqGrid").trigger("reloadGrid");
   }
</script>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
<jsp:include page="../include/footer.jsp"></jsp:include>
